package org.example.dialogue.controller;

import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.example.ai.result.Result;
import org.example.dialogue.form.MessageForm;
import org.example.dialogue.vo.MessageVo;
import org.example.dialogue.service.ServiceDialogueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zqtao
 */

@Slf4j
@RestController
@RequestMapping("/dialogue")
public class ServiceDialogueController {

    @Autowired
    private ServiceDialogueService serviceDialogueService;

    @Operation(summary = "调用文心一言AI大模型实现对话")
    @PostMapping("/getMessages")
    public Result<List<MessageVo>> getMessage(@RequestBody List<MessageForm> messageForms, @RequestParam Long userId, @RequestParam Integer initValue) {
        return Result.ok(serviceDialogueService.getMessage(messageForms,userId, initValue));
    }

    @Operation(summary = "新建对话时，保存对话记录")
    @GetMapping("/saveMessages/{userId}")
    public Result<String> saveMessage(@PathVariable Long userId) {
        return Result.ok(serviceDialogueService.saveMessage(userId));
    }

    @Operation(summary = "新建对话")
    @GetMapping("/initializeChat/{userId}")
    public Result<Integer> initializeChat(@PathVariable Long userId){
        return Result.ok(serviceDialogueService.initializeChat(userId));
    }

    @Operation(summary = "删除对话记录")
    @DeleteMapping("/deleteChat/{conversationId}")
    public Result<String> deleteChat(@PathVariable Integer conversationId) {
        return Result.ok(serviceDialogueService.deleteChat(conversationId));
    }



}
